package com.example.dubboconsumer.controller;

import org.apache.dubbo.config.annotation.Reference;
import com.example.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    //将生产者注册到Dubbo映射到该对象上, 这里完成了服务之间的调用
    @Reference
    private UserService userService;

    @RequestMapping(value = "/getUserById", method = RequestMethod.GET)
    public Object getUserById(@RequestParam("id") int id) {
        return userService.getUserById(id);
    }
}
